<template>
	<view class="takaway">
		<view class="t1">
			<text>大连</text>
			<u-search v-model="value" @search="search" @custom="search"></u-search>
		</view>
		<swiper interval="3000" indicator-dots :circular="true" :autoplay="true">
			<swiper-item v-for="item in lun" @click="todetail(item.id)">
				<image :src="'http://124.93.196.45:10001'+item.advImg" style="width: 100%; height: 100%;"></image>
			</swiper-item>
		</swiper>
		<u-grid col="5" :border="true">
			<u-grid-item v-for="item in type" style="margin-top: 20px; margin-bottom: 10px;" @click="toclassify(item.id)">
				<image :src="'http://124.93.196.45:10001'+item.imgUrl" style="width: 60px; height: 60px;"></image>
				<text>{{item.themeName}}</text>
			</u-grid-item>
		</u-grid>
		<text style="font-size: 28px; color: red;">推荐好店</text>
		<view class="t2">
			<view class="t3" v-for="item in tuijian" @click="todetail(item.id)">
				<image :src="'http://124.93.196.45:10001'+item.imgUrl"></image>
				<text>{{item.name}}</text>
				<view class="t4">
					<text>评分：{{item.score}}</text>
					<text>3小时下单数：{{item.saleNum3hour}}</text>
				</view>
			</view>
		</view>
		<text style="font-size: 28px; color: firebrick;">附近商家</text>
		<view class="t5">
			<view class="t6" v-for="item in list" @click="todetail(item.id)">
				<image :src="'http://124.93.196.45:10001'+item.imgUrl"></image>
				<view class="t7">
					<text>{{item.name}}</text>
					<view class="t8">
						<text>评分：{{item.score}}</text>
						<text style="margin-left: 30px;">月销量：{{item.saleQuantity}}单</text>
					</view>
					<text>人均消费：{{item.avgCost}}元</text>
					<text>到店距离：{{item.distance}}米</text>
					<text>到店时间：{{item.deliveryTime}}分钟</text>
				</view>
			</view>
		</view>
		<u-tabbar>
			<u-tabbar-item text="首页" icon="home-fill"></u-tabbar-item>
			<u-tabbar-item text="订单" icon="coupon" @click="toident"></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" @click="tomy"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lun:[],
				type:[],
				tuijian:{},
				list:[],
				value:''
			}
		},
		onLoad() {
			this.getlun()
			this.gettype()
			this.gettuijian()
			this.getlist()
		},
		methods: {
			getlun(){
				this.api.get('/prod-api/api/takeout/rotation/list').then(res=>{
					this.lun=res.data.rows
				})
			},
			gettype(){
				this.api.get('/prod-api/api/takeout/theme/list').then(res=>{
					this.type=res.data.data
				})
			},
			gettuijian(){
				this.api.get('/prod-api/api/takeout/seller/list?recommend=Y').then(res=>{
					this.tuijian=res.data.rows
				})
			},
			getlist(){
				this.api.get('/prod-api/api/takeout/seller/list').then(res=>{
					this.list=res.data.rows
				})
			},
			toident(){
				uni.redirectTo({
					url:'/pages/other/takaway/indent/indent'
				})
			},
			tomy(){
				uni.redirectTo({
					url:'/pages/other/takaway/My/My'
				})
			},
			search(){
				uni.navigateTo({
					url:'/pages/other/takaway/taksearch/taksearch?name='+this.value
				})
				this.value=''
			},
			toclassify(id){
				uni.navigateTo({
					url:'/pages/other/takaway/takeclassify/takeclassify?id='+id
				})
			},
			todetail(id){
				uni.navigateTo({
					url:'/pages/other/takaway/takeawayDetail/takeawayDetail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
.t1{
	display: flex;
}
.t2{
	display: flex;
	flex-wrap: wrap;
	margin-top: 10px;
	.t3{
		font-size: 13px;
		display: flex;
		flex-direction: column;
		width: 44%;
		margin-left: 15px;
		line-height: 30px;
		image{
			border-radius: 15px;
			width: 170px;
			height: 170px;
		}
		.t4{
			display: flex;
			justify-content: space-between;
		}
	}
}
.t5{
	.t6{
		display: flex;
		line-height: 30px;
		border-top: 1px solid salmon;
		margin-top: 20px;
		image{
			width: 125px;
			height: 125px;
			border-radius: 15px;
			margin-top: 15px;
		}
		.t7{
			margin-left: 15px;
			display: flex;
			flex-direction: column;
			.t8{
				display: flex;
				justify-content: space-between;
			}
		}
	}
}
</style>
